package com.banban.user.controller;

import com.banban.user.domain.UserProfile;
import com.banban.user.dto.UpdateUserProfileDTO;
import com.banban.user.dto.UserProfileDTO;
import com.banban.user.service.UserProfileService;
import com.banban.user.vo.DataResult;
import com.banban.user.vo.UserProfileVO;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

@RestController
@RequestMapping("/userProfile")
public class UserProfileController {

    @Resource
    private UserProfileService service;

    @PostMapping("/getUserProfile")
    public DataResult getUserProfile(@RequestBody @Valid UserProfileDTO dto){
        UserProfileVO vo = service.getUserProfile(dto);
        return DataResult.success(vo);
    }

    @PostMapping("/getList")
    public DataResult getList(@RequestBody UserProfileDTO dto){
        List<UserProfile> vo = service.getList(dto);
        return DataResult.success(vo);
    }

    @PostMapping("/updateUserProfile")
    public DataResult updateUserProfile(@RequestBody UpdateUserProfileDTO dto){
        service.updateUserProfile(dto);
        return DataResult.success();
    }

    @PostMapping("/delete")
    public DataResult delete(@RequestBody UpdateUserProfileDTO dto){
        service.deleteUserProfile(dto);
        return DataResult.success();
    }
}
